{% extends "base.html" %}

{% block head-title %}{{algorithm.algorithm_name}}{% endblock %}

{% block title %}{{ algorithm.algorithm_name }}{% endblock %}

{% block content %}
<div style="float: right;">
	<a href="/static/{{algorithm.instance_id}}/{{algorithm.data_source_name}}"
		class="uk-button uk-button-success" target="_blank">数据文件</a>
	<a href="/static/{{algorithm.instance_id}}/result.xlsx"
		class="uk-button uk-button-danger" target="_blank">关联规则</a>
	<a href="/show_source_code?instance_id={{algorithm.instance_id}}"
		class="uk-button uk-button-primary" target="_blank">源代码</a>
</div>
<h2>数据源</h2>
<table class="uk-table uk-table-striped">
	<caption>记录数:{{algorithm.data_source_size}}</caption>
	<thead>
		<tr>
			<th>序号</th> 
			{% for column in algorithm.data_source.columns %}
			<th>{{ column }}</th> 
			{% endfor %}
		</tr>
	</thead>
	<tbody>
		{% for values in algorithm.data_source.head.values %}
		<tr>
			<td>{{ forloop.counter }}</td>
			{% for value in values%}
			<td>{{ value }}</td>
			{% endfor %}
		</tr>
		{% endfor %}
	</tbody>
</table>
<hr />

<h2>模型</h2>
<table class="uk-table uk-table-striped">
	<thead>
		<tr>
			<th>项目</th>
			<th>内容</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>【订单ID】字段</td>
			<td>{{ algorithm.transaction_id_name }}</td>
		</tr>
		<tr>
			<td>【订单项目】字段</td>
			<td>{{ algorithm.transaction_goods_name }}</td>
		</tr>
		<tr>
			<td>最小支持度</td>
			<td>{{ algorithm.min_support }}</td>
		</tr>
		<tr>
			<td>最小可信度</td>
			<td>{{ algorithm.min_confidence }}</td>
		</tr>
		<tr>
			<td>关联规则条数</td>
			<td>{{ algorithm.rules | length }}</td>
		</tr>
	</tbody>
</table>
<hr />

<h2>关联规则</h2>
<table class="uk-table uk-table-striped">
	<thead>
		<tr>
			<th>序号</th>
			<th>前项</th>
			<th>后项</th>
			<th>支持度</th>
			<th>可信度</th>
		</tr>
	</thead>
	<tbody>
		{% for rule in algorithm.rules %}
		<tr>
			<td>{{ forloop.counter }}</td>
			<td>{{ rule.lhs | join:"+" }}</td>
			<td>{{ rule.rhs | join:"+" }}</td>
			<td>{{ rule.support | floatformat:2 }}</td>
			<td>{{ rule.confidence| floatformat:2  }}</td>
		</tr>
		{% endfor %}
	</tbody>
</table>
<hr />
{% endblock %}